package priv.yiyuan.example.design.proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * 配置服务类
 * <p>
 * 真实主题
 *
 * @author YiYuan
 * @data 2025/9/24
 * @apoNote
 */
public class ConfigurationService {

    private Map<String, String> configCache = new HashMap<>();

    public String getConfig(String key) {

        System.out.println("正在从数据源加载配置项: " + key + "...");

        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }

        String value = "配置值_" + key + "_" + System.currentTimeMillis();
        System.out.println("加载完成, 配置项 " + key + " 的值为: " + value);
        return value;
    }

    public void updateConfig(String key, String value) {
        System.out.println("正在更新配置项: " + key + " 为 " + value + "...");
        System.out.println("配置项 " + key + " 更新成功。");
    }
}
